home *** CD-ROM | disk | FTP | other *** search
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/locale.h>
- #include <exec/memory.h>
- #include <dos/rdargs.h>
-
- static __saveds __asm void PrintHookFunc(register __a1 LONG);
-
- struct Arguments {LONG PrintTime;};
-
- struct DosLibrary *DOSBase;
-
- LONG __saveds main(void)
- {
- UBYTE ProgName[80];
- LONG rcode=RETURN_OK;
- struct RDArgs *Args;
- struct Library *LocaleBase ;
- static const struct Hook PrintHook = {{NULL,NULL},(void*)(&PrintHookFunc),NULL,NULL};
- static struct Arguments args={0};
-
- if(DOSBase = (struct DosLibrary*)OpenLibrary("dos.library",37))
- {
- GetProgramName(ProgName,sizeof(ProgName));
- if(LocaleBase = OpenLibrary("locale.library",38))
- {
- if(Args = ReadArgs("Time/S",(LONG*)(&args),NULL))
- {
- static struct DateStamp ds;
- struct Locale *loc;
- loc = OpenLocale(NULL);
- DateStamp(&ds);
- FormatDate(loc,args.PrintTime?"%Y%m%d%H%M%S\n":"%Y%m%d\n",&ds,(struct Hook*)&PrintHook);
- CloseLocale(loc);
- FreeArgs(Args);
- } else
- {
- PrintFault(IoErr(),ProgName);
- rcode = RETURN_WARN;
- }
- CloseLibrary(LocaleBase);
- } else
- {
- Printf("%s: error opening %s V38!\n",ProgName,"locale.library");
- rcode = RETURN_FAIL;
- }
- CloseLibrary((struct Library*)DOSBase);
- } else rcode=RETURN_FAIL;
- return rcode;
- }
-
- static __saveds __asm void PrintHookFunc(register __a1 LONG c) {UBYTE s[2]; s[0]=c; s[1]='\0'; PutStr(s); }
-